﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Hisun.Models;
using Hisun.Controllers;

namespace Hisun.View.ReportQuery
{
    public partial class Report_CPCBHZB :AbcPageBase
    {
        HisunDBDataContext db = new HisunDBDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var MyProductList = from a in db.TABC_JS_Product
                                    orderby a.产品账户ID, a.产品账户名称
                                    select new
                                    {
                                        a.产品账户ID,
                                        a.产品账户名称
                                    };

                DropDownList_Product.Items.Clear();
                foreach (var MyProduct in MyProductList)
                {
                    DropDownList_Product.Items.Add(new ListItem(MyProduct.产品账户ID + "|" + MyProduct.产品账户名称, MyProduct.产品账户ID));



                }

                AbcFullAccountPeriod MyFullAp = new AbcFullAccountPeriod();

                MyFullAp.FullAccountPeriodToDropdownlist_Year(DropDownList_Year, Application["accountPeriod"].ToString());


            }
        }







        protected void Button_QueryLine_Click(object sender, EventArgs e)
        {
            CostReport MyReport = new CostReport();
            string myProductAccount =  DropDownList_Product.SelectedValue.ToString();

            string myYear = DropDownList_Year.SelectedValue.ToString();
            string UserName = Session[ServerVars.sysSessionUserName].ToString();
            string myHtmlReport = "";
            if (CheckBox_Unit.Checked == false)
            {
                myHtmlReport = MyReport.WriteExcel_Report_CPCBHZB(myProductAccount, myYear, UserName);
            }
            else
            {
                myHtmlReport = MyReport.WriteExcel_Report_CPCBHZB_UNIT(myProductAccount, myYear, UserName);
            }
          
            Response.Redirect("/Report/UserReport/" + myHtmlReport + ".html");
        }




    }
}
